package com.zhiliao.adapter.demo2;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleServletHandlerAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zouxf Department:3cs
 * @copyright Copyright 2021-2021 JD.COM All Right Reserved
 * @create Date 2021/6/30 9:28
 * @description
 * @lastModifiedBy
 * @lastModifiedDate(yyyy/MM/dd)
 * @see
 */
@Component
public class CustomAdapter extends SimpleServletHandlerAdapter {
    @Override
    public boolean supports(Object o) {
        System.out.println(o.getClass());
        return o instanceof HelloAction;
    }

    @Override
    public ModelAndView handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        ((HelloAction) o).ma();
        return null;
    }

    @Override
    public long getLastModified(HttpServletRequest httpServletRequest, Object o) {
        return 0;
    }
}
